import React, { useState, useEffect } from "react";
import { Image } from "antd";
import { Input, Select, BatchSuffixInput } from "@/views/components/PrefixPlaceholder";
import { NumText } from "@/pages/OrderModule/common/components/CommonText";
import CommonStoreSearchInput from "@/views/components/CommonStoreSearchInput/index";

export default ({}) => {
	const defaultColumns = [
		{
			name: "序号",
			code: "index",
			lock: true,
			render: (t, r, i) => {
				if (r.id) return r.id;
				if (r.sonId) return r.sonId;
			},
			width: 100
		},
		{
			name: "供应商",
			code: "supplierName",
			search: {
				order: 1,
				content: () => <CommonStoreSearchInput type="storeName" placeholder="供应商名称" />
			},
			width: 200
		},
		{
			name: "所属区域编码",
			code: "supplierArea",
			search: { order: 2, content: () => <BatchSuffixInput allowClear clearable placeholder="所属区域编码" /> }
		},
		{
			name: "商品图片",
			code: "skuImage",
			width: 200,
			render: (value, record, i) => {
				if (!value) return "";
				return <Image width={60} src={value} />;
			}
		},
		{
			name: "商品编码",
			code: "skuCode",
			search: {
				order: 4,
				content: () => <Input allowClear placeholder="商品编码" />
			}
		},
		{
			name: "款式编码",
			code: "spuCode",
			search: {
				order: 3,
				content: () => <Input allowClear placeholder="款式编码" />
			}
		},
		{
			name: "商品名称",
			code: "skuName",
			width: 200,
			search: {
				order: 5,
				content: () => <Input allowClear placeholder="商品名称" />
			}
		},
		{
			name: "颜色规格",
			code: "skuSpec",
			search: {
				order: 6,
				content: () => <Input allowClear placeholder="颜色规格" />
			}
		},
		{
			name: "采购数量",
			code: "allCount"
		},
		{
			name: "采购单价",
			code: "skuPrice",
			render: (text, record, index) => (
				<div>
					{text && <NumText as="s1" pre="¥" num={text} />}
					<div style={{ marginRight: "10px" }}>
						{record.priceType == 2 && <span style={{ color: "#fff", background: "rgba(240, 61, 41, 1)" }}>VIP</span>}
					</div>
				</div>
			)
		},
		{
			name: "采购金额",
			code: "allPrice",
			render: text => <div style={{ color: "rgba(240, 61, 41, 1)" }}>{text && <span>￥{text.toFixed(2)}</span>}</div>
		}
	];
	return { defaultColumns };
};
